package leetcode.code1497;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public boolean canArrange(int[] arr, int k) {
		int[] cnts = new int[k];
		for (int num : arr) {
			cnts[(num % k + k) % k]++;
		}
		if (cnts[0] % 2 != 0 || (k % 2 == 0 && cnts[k / 2] % 2 != 0)) {
			return false;
		}
		for (int i = 1; i <= (k >> 1); i++) {
			if (cnts[i] != cnts[k - i]) {
				return false;
			}
		}
		return true;
	}

	@Override
	public void debug4() {
		H.compare(false, this.canArrange(H.str2array3("[-1,-1,-1,-1,2,2,-2,-2]"), 3));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		System.out.println(-1%3);
		System.out.println(-2%3);
	}

}
